package com.ruoyi.yunxin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yunxin.domain.VoiceTemplateConfig;
import com.ruoyi.yunxin.service.IVoiceTemplateConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 云信设置Controller
 * 
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/voiceTemplateConfig/voiceTemplateConfig")
public class VoiceTemplateConfigController extends BaseController
{
    @Autowired
    private IVoiceTemplateConfigService voiceTemplateConfigService;

    /**
     * 查询云信设置列表
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(VoiceTemplateConfig voiceTemplateConfig)
    {
        startPage();
        List<VoiceTemplateConfig> list = voiceTemplateConfigService.selectVoiceTemplateConfigList(voiceTemplateConfig);
        return getDataTable(list);
    }

    /**
     * 导出云信设置列表
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:export')")
    @Log(title = "云信设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VoiceTemplateConfig voiceTemplateConfig)
    {
        List<VoiceTemplateConfig> list = voiceTemplateConfigService.selectVoiceTemplateConfigList(voiceTemplateConfig);
        ExcelUtil<VoiceTemplateConfig> util = new ExcelUtil<VoiceTemplateConfig>(VoiceTemplateConfig.class);
        util.exportExcel(response, list, "云信设置数据");
    }

    /**
     * 获取云信设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(voiceTemplateConfigService.selectVoiceTemplateConfigById(id));
    }

    /**
     * 新增云信设置
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:add')")
    @Log(title = "云信设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VoiceTemplateConfig voiceTemplateConfig)
    {
        return toAjax(voiceTemplateConfigService.insertVoiceTemplateConfig(voiceTemplateConfig));
    }

    /**
     * 修改云信设置
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:edit')")
    @Log(title = "云信设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VoiceTemplateConfig voiceTemplateConfig)
    {
        return toAjax(voiceTemplateConfigService.updateVoiceTemplateConfig(voiceTemplateConfig));
    }

    /**
     * 删除云信设置
     */
    @PreAuthorize("@ss.hasPermi('voiceTemplateConfig:voiceTemplateConfig:remove')")
    @Log(title = "云信设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(voiceTemplateConfigService.deleteVoiceTemplateConfigByIds(ids));
    }
}
